package com.lei.android.videoline.VideoLineView;

import android.content.res.Resources;

/**
 * 通用工具类
 * Created by HDL on 2017/9/4.
 */

public class CUtils {
    /**
     * dp转px
     *
     * @return
     */
    public static int dp2px(float dipValue) {
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f * (dipValue >= 0 ? 1 : -1));
    }

    /**
     * sp转换成px
     */
    public static int sp2px(float spValue) {
        float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity;
        return (int) (spValue * fontScale + 0.5f * (spValue >= 0 ? 1 : -1));
    }

}
